﻿#if WINDOWS_PHONE
#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2010-11-26 16:51:23Z</CreationDate>
</File>
*/
#endregion

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using Microsoft.Phone.Tasks;

namespace Outcoder.LauncherModel.Launchers
{
	public class EmailComposeLauncher : LauncherBase, IEmailComposeLauncher
	{
		readonly EmailComposeTask task = new EmailComposeTask();

		public override async Task<bool> ShowAsync()
		{
			Show();

			return true;
		}

		void Show()
		{
			task.To = String.Join(";", toList);
			task.Cc = String.Join(";", toList);

			task.Show();
		}

		public string Body
		{
			get
			{
				return task.Body;
			}
			set
			{
				task.Body = value;
			}
		}

		readonly List<string> toList = new List<string>();

		public IList<string> ToList
		{
			get
			{
				return toList;
			}
		}

		readonly List<string> ccList = new List<string>();

		public IList<string> CCList
		{
			get
			{
				return ccList;
			}
		}

		readonly List<string> bccList = new List<string>();

		public IList<string> BccList
		{
			get
			{
				return bccList;
			}
		}

		public string Subject
		{
			get
			{
				return task.Subject;
			}
			set
			{
				task.Subject = value;
			}
		}

		public int? CodePage
		{
			get
			{
				return task.CodePage;
			}
			set
			{
				task.CodePage = value;
			}
		}

		public string MimeType { get; set; }

		/// <summary>
		/// This is ignored in Windows Phone.
		/// </summary>
		public bool UseHtmlFormat { get; set; }

		/// <summary>
		/// Always returns <c>true</c> on Windows Phone.
		/// </summary>
		public bool CanSendMail
		{
			get
			{
				return true;
			}
		}
	}
}
#endif